﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JzSport.WebApp.Module_APP_AD
{
    public partial class Query : System.Web.UI.Page
    {
        public string StringTotal;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                DateTime now = DateTime.Now;
                ctlEditBeginTime.Text = now.ToString("yyyy-MM-dd");
                ctlEditEndTime.Text = now.ToString("yyyy-MM-dd");
            }
        }

        protected void ctlBtnQuery_Click(object sender, EventArgs e)
        {
            DateTime beginTime = Convert.ToDateTime(ctlEditBeginTime.Text);
            DateTime endTime = Convert.ToDateTime(ctlEditEndTime.Text);
            beginTime = new DateTime(beginTime.Year, beginTime.Month, beginTime.Day, 0, 0, 0);
            endTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);

            string app = ctlEditApp.Text.Trim();
            List<Jiz.App.Domain.Datas.AdClickCount> list = new Jiz.App.Domain.Services.QueryService().QueryByApp(app,
                 ctlEditSalesman.Text,
                 beginTime, endTime);
            _ctlList.DataSource = list;
            _ctlList.DataBind();

            int total = 0;
            for(int index = 0; index < list.Count; index++)
            {
                total += list[index].Count;
            }
            StringTotal = total.ToString();
        }
    }
}